from functools import wraps
from fastapi import Request


def InnerAuth():
    return None


def ApiEncrypt(response: bool = False):
    """
    接口加密
    响应加密忽略，默认不加密，为 true 时加密

    """
    def decorator(func):
        @wraps(func)
        async def wrapper(*args, **kwargs):
            req: Request = kwargs.get('req')

            print("---------------加密接口:")
            result = await func(*args, **kwargs)

            return result
        return wrapper

    return decorator


def EncryptField(algorithm: str = '', password: str = '', publicKey:str = '', privateKey: str = '', encode: str = ''):
    """
    接口加密

    """
    def decorator(func):
        @wraps(func)
        async def wrapper(*args, **kwargs):
            req: Request = kwargs.get('req')

            print("---------------加密字段:")
            result = await func(*args, **kwargs)

            return result
        return wrapper

    return decorator